﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package Modules.guide {
    import Engine.Managers.*;
    import Modules.guide.actions.*;

    public class GuideActionReader {

        protected static const ACTIONS:Object = {
            TutorialStart:GATutorialStart,
            TutorialEnd:GATutorialEnd,
            DisplayGuideTile:GADisplayGuideTile,
            DisplayDialog:GADisplayDialog,
            DisplayArrow:GADisplayArrow,
            DisplayMask:GADisplayMask,
            DisplaySpotlight:GADisplaySpotlight,
            GameModePlayFiltered:GAGameModePlayFiltered,
            Notify:GANotify,
            Function:GAFunc,
            AllowQuests:GAAllowQuests,
            ShowNews:GAShowNews,
            WaitForTransaction:GAWaitForTransaction,
            WaitForPredicate:GAWaitForPredicate,
            WaitForClickAnywhere:GAWaitForClickAnywhere,
            WaitForZoom:GAWaitForZoom,
            WaitForWilderness:GAWaitForWilderness,
            RemoveElements:GARemoveElements,
            Pause:GAPause,
            WaitForTransactionOrGameMode:GAWaitForTransactionOrGameMode,
            WaitForTransactionOrNotGameMode:GAWaitForTransactionOrNotGameMode,
            WaitForTransactionOrClickGround:GAWaitForTransactionOrClickGround,
            PanMap:GAPanMap,
            WaitForPredicateOrClickAnywhere:GAWaitForPredicateOrClickAnywhere,
            RefreshResources:GARefreshResources
        };

        protected var m_guide:Guide;

        public function GuideActionReader(_arg1:Guide){
            this.m_guide = _arg1;
        }
        public function readActions():void{
            var _local3:XML;
            var _local4:GuideSequence;
            var _local5:Boolean;
            var _local6:XMLList;
            var _local7:XML;
            var _local8:String;
            var _local9:Class;
            var _local10:GuideAction;
            var _local1:XML = Global.gameSettings.getXML();
            if (!_local1){
                ErrorManager.addError("Missing game settings!");
                return;
            };
            var _local2:XMLList = _local1.guides.guide;
            for each (_local3 in _local2) {
                _local4 = new GuideSequence(this.m_guide);
                _local5 = _local4.createFromXml(_local3);
                if (_local5){
                    this.m_guide.registerSequence(_local4);
                    _local6 = _local3.action;
                    for each (_local7 in _local6) {
                        _local8 = String(_local7.@name);
                        _local9 = ACTIONS[_local8];
                        if (_local9 != null){
                            _local10 = (new (_local9)() as GuideAction);
                            _local10.setGuide(this.m_guide, _local4);
                            if (_local10.createFromXml(_local7)){
                                _local4.addAction(_local10);
                            } else {
                                ErrorManager.addError(("Failed to parse tutorial step for " + _local8));
                            };
                        } else {
                            ErrorManager.addError(("Unknown tutorial action: " + _local8));
                        };
                    };
                };
            };
        }

    }
}//package Modules.guide 
